package lt.marsrutai.mobile.android.activity;

import java.util.List;

import lt.marsrutai.mobile.android.R;
import lt.marsrutai.mobile.android.manager.AboutPreferenceManager;
import lt.marsrutai.mobile.android.manager.CachePreferenceManager;
import lt.marsrutai.mobile.android.manager.StopSearchPreferenceManager;
import android.os.Build;
import android.os.Bundle;

import com.actionbarsherlock.app.SherlockPreferenceActivity;

public class AppPreferenceActivity extends SherlockPreferenceActivity {

    @SuppressWarnings("deprecation")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
            addPreferencesFromResource(R.xml.preferences);
            addPreferencesFromResource(R.xml.preferences_stop_search);
            addPreferencesFromResource(R.xml.preferences_about);

            CachePreferenceManager cachePrefManager = new CachePreferenceManager(this, this);
            cachePrefManager.registerListeners();
            cachePrefManager.updateCurrentRequestCacheSize();
            
            StopSearchPreferenceManager stopSearchPrefManager = new StopSearchPreferenceManager(this, this);
            stopSearchPrefManager.registerListeners();
            stopSearchPrefManager.updateNearbyStopRadiusSumary();

            new AboutPreferenceManager(this, this).registerListeners();
        }
    }

    @Override
    public void onBuildHeaders(List<Header> target) {
        loadHeadersFromResource(R.xml.preference_headers, target);
    }

}
